import { Actions } from 'react-native-router-flux';

// antd 按需加载
import { Toast, Portal } from '@ant-design/react-native';

import store from '../../../store/store.js'
import * as ActionTypes from '../../../constants/constants.js'
import { isUser, isWxUser, path, saveData, loadData, removeData, requstPromise } from '../../../util/utils.js'
import request from '../../../api/request.js'

export async function checkOrders(options) {
    const { dispatch } = this.props
    const loading = Toast.loading('加载中', 0, null, false)
    const res = await request.MemberController.checkOrders(options)
    Portal.remove(loading)
    return requstPromise(res)
}

export async function addPurchase(options) {
    const { dispatch } = this.props
    const res = await request.PurchaseController.addPurchase(options)
    if (res.data.code == 200) {
        Toast.success('预约成功', 2, () => {
            Actions.orderList()
        }, false)
    } else {
        Toast.fail('提交失败', 1, null, false)
    }
    // return requstPromise(res)
}

export async function promptlyConfirmOrder(options) {
    const { dispatch } = this.props
    const res = await request.PortalOrderController.promptlyConfirmOrder(options)
    return requstPromise(res)

}
